package com.jianbing.north.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jianbing.common.annotation.Log;
import com.jianbing.common.core.controller.BaseController;
import com.jianbing.common.core.domain.AjaxResult;
import com.jianbing.common.enums.BusinessType;
import com.jianbing.north.domain.NorthDayPlan;
import com.jianbing.north.service.INorthDayPlanService;
import com.jianbing.common.utils.poi.ExcelUtil;
import com.jianbing.common.core.page.TableDataInfo;

/**
 * 每天能够解锁的partController
 * 
 * @author ruoyi
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/shasha/plan")
public class NorthDayPlanController extends BaseController
{
    @Autowired
    private INorthDayPlanService northDayPlanService;

    /**
     * 查询每天能够解锁的part列表
     */
    // @PreAuthorize("@ss.hasPermi('shasha:plan:list')")
    @GetMapping("/list")
    public TableDataInfo list(NorthDayPlan northDayPlan)
    {
        startPage();
        List<NorthDayPlan> list = northDayPlanService.selectNorthDayPlanList(northDayPlan);
        return getDataTable(list);
    }

    /**
     * 导出每天能够解锁的part列表
     */
    // @PreAuthorize("@ss.hasPermi('shasha:plan:export')")
    @Log(title = "每天能够解锁的part", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NorthDayPlan northDayPlan)
    {
        List<NorthDayPlan> list = northDayPlanService.selectNorthDayPlanList(northDayPlan);
        ExcelUtil<NorthDayPlan> util = new ExcelUtil<NorthDayPlan>(NorthDayPlan.class);
        util.exportExcel(response, list, "每天能够解锁的part数据");
    }

    /**
     * 获取每天能够解锁的part详细信息
     */
    // @PreAuthorize("@ss.hasPermi('shasha:plan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(northDayPlanService.selectNorthDayPlanById(id));
    }

    /**
     * 新增每天能够解锁的part
     */
    // @PreAuthorize("@ss.hasPermi('shasha:plan:add')")
    @Log(title = "每天能够解锁的part", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NorthDayPlan northDayPlan)
    {
        return toAjax(northDayPlanService.insertNorthDayPlan(northDayPlan));
    }

    /**
     * 修改每天能够解锁的part
     */
    //  @PreAuthorize("@ss.hasPermi('shasha:plan:edit')")
    @Log(title = "每天能够解锁的part", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NorthDayPlan northDayPlan)
    {
        return toAjax(northDayPlanService.updateNorthDayPlan(northDayPlan));
    }

    /**
     * 删除每天能够解锁的part
     */
    //   @PreAuthorize("@ss.hasPermi('shasha:plan:remove')")
    @Log(title = "每天能够解锁的part", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(northDayPlanService.deleteNorthDayPlanByIds(ids));
    }
}
